package org.scalpel.HHObjects;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.scalpel.common.HHObject;

import android.util.Log;

public class HHObjectInspector extends HHObject {
	
	HashMap<String, Object> fListObject = null;
	
	public void setObjectList( HashMap<String, Object> listObject )
	{
		fListObject = listObject;
		for( String name : getObjectNameList())
		{
			String s = getMethodList(name).toString();
			Log.i("HHObjectInspector", s);
		}
	}
	
	public HHObjectInspector(String fName) {
		super(fName);
	}

	public List<String> getObjectNameList(){
		List<String> res = new ArrayList<String>();
		
		Set<String> cles = fListObject.keySet();
    Iterator<String> it = cles.iterator();
    while (it.hasNext()){
       String cle = it.next();
       //HHObject valeur = (HHObject)fListObject.get(cle);
       res.add(cle);
    }
    return res;
	}
	
	@SuppressWarnings("rawtypes")
	public List<String> getMethodList(String className){
		/* ["public java.lang.Object org.scalpel.common.Loader(java.lang.String)",
		 *  "public void org.scalpel.common.onLoad()",
		 * ]
		 */
		HHObject o = (HHObject)fListObject.get(className);
		Class c = o.getClass();
		Constructor[] constructors = c.getConstructors();
		Method[] methods= c.getDeclaredMethods();
		
		List<String> res = new ArrayList<String>(); 
		
		for(Constructor cons : constructors)
			res.add(cons.toString());
		
		for(Method meth : methods)
			res.add(meth.toString());

		return res;
	}
	
	
	
	
	
	@Override
	public void finish() {
		// TODO Auto-generated method stub

	}

}
